<template>
	<view>
		<view class="tit">
			<image src="../../static/first/zs.png"></image>
			<view>您的公司信息</view>
		</view>
		<view class="content">
			<view class="phone">
				<text>企业名称</text>
				<input class="uni-input" v-model="query.name" focus placeholder="请输入您的企业名称" />
			</view>
			<view class="phone">
				<text>三证合一编号</text>
				<input class="uni-input" v-model="query.registrationNumber" focus placeholder="请输入三证合一编号" />
			</view>
			<view class="phone">
				<text>企业联系人</text>
				<input class="uni-input" v-model="query.contactPerson" focus placeholder="请输入企业联系人	" />
			</view>
			<view class="phone">
				<text>联系人手机号</text>
				<input class="uni-input" v-model="query.contactPhone" focus placeholder="请输入联系人手机号" />
			</view>
		</view>
		<view class="btn">
			<button @click="updateEnterprise">修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				codeText: "获取验证码",
				showBtnOn: false,
				timer: null,
				count: '',
				query: {
					name: '',
					registrationNumber: '',
					contactPerson: '',
					contactPhone: '',
					id: ''
				}
			}
		},
		onLoad() {
			this.ftEnterprise()
		},
		methods: {
			//提示
			showToast(title) {
				uni.showToast({
					title: title,
					icon: 'none'
				})
			},
			//获取关联的企业信息
			ftEnterprise() {
				let userInfo = uni.getStorageSync('userInfo')
				uni.request({
					url: this.$serverUrl + 'ftEnterprise',
					data: {
						"userId": userInfo.id
					},
					success: (res) => {
						let data = res.data.content[0]
						this.query.name = data.name
						this.query.registrationNumber = data.registrationNumber
						this.query.contactPerson = data.contactPerson
						this.query.contactPhone = data.contactPhone
						this.query.id = data.id
					},
					fail: (e) => {
						this.showToast('关联公司信息获取失败')
					}
				})
			},
			//修改企业信息
			updateEnterprise() {
				uni.request({
					url: this.$serverUrl + 'ftEnterprise',
					data: {
						"name": this.query.name,
						"registrationNumber": this.query.registrationNumber,
						"contactPerson": this.query.contactPerson,
						"contactPhone": this.query.contactPhone,
						"id": this.query.id
					},
					method: 'PUT',
					success: (res) => {
						this.showToast('修改成功')
					},
					fail: (e) => {
						this.showToast('修改失败')
					}
				})
			}
		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #F5F5F5;
		overflow-y: hidden;
	}

	.tit {
		margin: 36upx;
		display: flex;
		align-items: flex-end;
	}

	.tit image {
		width: 22upx;
		height: 26upx;
	}

	.tit view {
		margin-left: 26upx;
		font-size: 32upx;
		font-weight: bold;
	}

	.content {
		background-color: #FFFFFF;
		color: #333333;
	}

	.phone {
		height: 124upx;
		display: flex;
		align-items: center;
	}

	.phone text {
		margin: 0 88upx 0 36upx;
	}

	.getCode {
		font-size: 28upx;
		color: #00B2CA;
	}

	/* 添加按钮 */
	.btn {
		width: 100%;
		height: 124upx;
		position: fixed;
		bottom: 0;
		background-color: #FFFFFF;
	}

	.btn button {
		margin: 0upx 36upx;
		background-color: #00B2CA;
		color: #FFFFFF;
	}
</style>
